package stream.Demo07;

import stream.Demo06.Student;

import java.io.FileInputStream;
import java.io.ObjectInputStream;

/**
 * @Author Miku
 * @Create 2021/4/30 9:17
 * 使用ObjectInputStream实现反序列化(读取重构成对象)
 * 序列化多个对象时，可使用List集合实现
 */
public class Test {
    public static void main(String[] args) throws Exception {
        //1.创建对象流
        FileInputStream fis = new FileInputStream("e:\\stu.bin");
        ObjectInputStream ois = new ObjectInputStream(fis);
        //2.读取文件(反序列化)
        Student s = (Student) ois.readObject();
        //3.关闭
        ois.close();
        System.out.println("执行完毕");
        System.out.println(s.toString());
    }
}
